package com.ljh.account.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ljh.account.dao.Req.SaveMoneyReq;
import com.ljh.account.dao.WishWall;
import com.ljh.account.mapper.WishWallMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WishWallService {
    @Autowired
    private WishWallMapper wishWallMapper;

    public void createWish(WishWall wish) {
        wishWallMapper.insertWish(wish);
    }

    public void updateWish(WishWall wish) {
        wishWallMapper.updateWish(wish);
    }

    public void deleteWish(Integer wishId) {
        wishWallMapper.deleteWish(wishId);
    }

    public WishWall getWishById(Integer wishId) {
        return wishWallMapper.selectWishById(wishId);
    }

    public PageInfo getAllWishesByUserId(Long userId,int page,int size) {
        PageHelper.startPage(page, size);
        List<WishWall> wishWalls = wishWallMapper.selectAllWishesByUserId(userId);
        return new PageInfo<>(wishWalls);
    }

    public void saveMoney(SaveMoneyReq params){
        wishWallMapper.savemoney(params);
    }

}
